<?php
@header("Content-Type:text/json;charset=utf-8");
@header("Access-Control-Allow-Origin:*");
$conn = mysqli_connect("b-sjisyki6cozhtk.bch.rds.gz.baidubce.com:3306", "b_sjisyki6cozhtk", "12345678", "b_sjisyki6cozhtk");

if (!isset($_POST["id"])) {
    exit('{"status":false,"message":"请传入完整参数"}');
}

$id = $_POST["id"]; // 对应字段名id接收数据

$sql = "select * from `sheet1` where id like '$id'";
$result = mysqli_query($conn, $sql);
$obj = array();
if ($result) { // 有结果对象 => 可能有数据
    $all = [];
    while ($item = mysqli_fetch_assoc($result)) {  // 解析成功 =>  返回关联数组  解析失败=>结束循环
        array_push($all, $item);
    }
    if (count($all)) {
        $obj["status"] = true;
        $obj["message"] = "OK";
        $obj["list"] =  $all;
    } else {
        $obj["status"] = true;
        $obj["message"] = "暂无数据!";
    }
} else {
    $obj["status"] = false;
    $obj["message"] = "sql语句有误";
    $obj["sql"] = $sql;
}
echo json_encode($obj);
